{assign var=div_id value="cntMediaItem_"|cat:$data.safe_gid }
<div class="cntMediaItem {$div_id|escape}">

{if $mode == 'item' }
<form class="handler__cntMediaDeleteForm" method="post" action="{$data.link_delete_form_submit|escape}">
<input type="hidden" name="div_id" value="{$div_id|escape}" />
<input type="hidden" name="item_title" value="{$item_title|escape}" />
<input type="hidden" name="media_group_id" value="{$data.media_group_id|escape}" />
{foreach from=$data.delete_formvars key=varname item=varvalue }
<input type="hidden" name="{$varname|escape}" value="{$varvalue|escape}" />
{/foreach}
</form>
{/if}

<form class="handler__cntMediaForm" method="post" action="{$data.link_form_submit|escape}" enctype="multipart/form-data">
<input type="hidden" name="div_id" value="{$div_id|escape}" />
<input type="hidden" name="item_title" value="{$item_title|escape}" />
<input type="hidden" name="media_group_id" value="{$data.media_group_id|escape}" />
{foreach from=$data.formvars key=varname item=varvalue }
<input type="hidden" name="{$varname|escape}" value="{$varvalue|escape}" />
{/foreach}

{include file="stddecor.form.open.tpl" }

{if $mode == 'item' }
<div class="right cntMedia_Box_ManagerShower"><a nohref="nohref" class="handler__cntMedia_ManagerShow light small" div_id="{$div_id|escape}">редактировать</a></div>
{/if}
<div class="cntMediaItem-header">
    {if $data.media_item.index }{$item_title|sprintf:$data.media_item.index}{else}{$item_title|sprintf:''}{/if}
</div>

{if $mode == 'item' }
<div>

    <table cellspacing="8" width="100%">
    <tr valign="top">
        <td class="cntMediaItem-td-preview">
            {if $data.media_item.extension == 'flv' }
                {assign var=tmp_preview value=$SPIcfg.dir.pubsite_styles|cat:'manage/image/cntMedia/preview_flv.gif' }
                <object type="application/x-shockwave-flash" data="{$SPIcfg.dir.pubsite_styles|escape}manage/flash/flashplayer.swf?1.00" width="360" height="302">
                    <param name="movie" value="{$SPIcfg.dir.pubsite_styles|escape}manage/flash/flashplayer.swf?1.00" />
                    <param name="allowfullscreen" value="true" />
                    <param name="allowscriptaccess" value="always" />
                    <param name="menu" value="false" />
                    <param name="wmode" value="transparent">
                    <param name="flashvars" value="menu=false&embed=fasle&image={$tmp_preview|escape}&file={$data.media_item.link_etalon|escape}&autostart=0" />
                    <p align="center"><b><a href="http://get.adobe.com/flashplayer" target="_blank">Install Adobe Flash</a></b></p>
                </object>
            {else}
                {if in_array( $data.media_item.extension, array( 'jpg', 'jpeg', 'gif', 'png' ) ) }
                    <div><img src="{$data.media_item.link_preview|spiMediaPreview:$SPIcfg.media.preview_width:$SPIcfg.media.preview_height|escape}" class="cntMediaItem-img-preview" /></div>
                {elseif in_array( $data.media_item.extension, array( 'swf' ) ) }
                    <div><img src="{$SPIcfg.dir.pubsite_styles|escape}manage/image/cntMedia/preview_swf.gif" class="cntMediaItem-img-preview" /></div>
                {elseif in_array( $data.media_item.extension, array( 'avi', 'wmv', 'mpg' ) ) }
                    <div><img src="{$SPIcfg.dir.pubsite_styles|escape}manage/image/cntMedia/preview_movie.gif" class="cntMediaItem-img-preview" /></div>
                {else}
                    <div><img src="{$SPIcfg.dir.pubsite_styles|escape}manage/image/cntMedia/preview_data.gif" class="cntMediaItem-img-preview" /></div>
                {/if}
            {/if}
            <div>
                <a href="{$data.media_item.link_download|escape}" class="tiny light" target="_blank">скачать оригинал {if $data.media_item.extension }(.{$data.media_item.extension|escape}){/if}</a>
            </div>
        </td>
        <td valign="top"><div class="small">{$data.media_item.description|escape|nl2br}</div></td>
    </tr>
    </table>
</div>
{/if}

<div class="cntMedia_Box_Manager {if $mode == 'item' }hidden{/if}">
    <div class="cntMediaItem-modify-form">
        <table cellspacing="5" width="100%">
        <tr valign="top">
            <td>
                <div class="small"><strong>Файл:</strong></div>
                <div><input type="file" name="uploadfile" class="handler__cntMedia_ManagerUploadfileBox" /></div>
                {if $data.allow_extensions_view }<div class="small light">Допустимые файлы: <strong>{$data.allow_extensions_view|escape}</strong></div>{/if}
                {if $data.upload_max_filesize   }<div class="small light">Максимальный размер файла: <strong>{$data.upload_max_filesize|escape}</strong></div>{/if}
                {if $mode == 'item' }<div class="small light">Если файл не указан - он обновляться не будет.</div>{/if}
            </td>

            <td width="150">
                {if $mode == 'item' }
                    <div class="small"><strong>Индекс сортировки:</strong></div>
                    <div><input type="text" name="order_index" value="{$data.media_item.order_index}" style="width: 80px;" /></div>
                {/if}
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <br />
                <div class="cntMedia_Box_DesciptionShower {if $data.media_item.description} hidden {/if}"><a nohref="nohref" class="handler__cntMedia_DescriptionShow small" div_id="{$div_id|escape}">добавить описание к файлу</a></div>
                <div class="cntMedia_Box_Desciption {if ! $data.media_item.description} hidden {/if}">
                    <div class="small"><strong>Описание:</strong></div>
                    <div><textarea name="description" class="textarea" cols="30" rows="4">{$data.media_item.description|escape}</textarea></div>
                    <div><a nohref="nohref" class="handler__cntMedia_DescriptionDrop small" div_id="{$div_id|escape}">удалить описание</a></div>
                </div>
            </td>
        </tr>
        </table>
    </div>

    <div class="cntMediaItem-errorMessageBox hidden"></div>

    <div align="center" style="padding: 8px 8px 0;">
        <table cellspacing="0" cellpadding="0" width="100%">
        <tr>
            <td align="left">
                <img src="{$SPIcfg.dir.pubsite_styles|escape}null.gif" class="cntMediaIco cntMediaIco_save" align="absmiddle" /> <a nohref="nohref" class="handler__cntMedia_ManagerSubmitForm" div_id="{$div_id|escape}">Сохранить</a>
                &nbsp;&nbsp;
                {if $mode == 'item' }
                <img src="{$SPIcfg.dir.pubsite_styles|escape}null.gif" class="cntMediaIco cntMediaIco_cancel" align="absmiddle" /> <a nohref="nohref" class="handler__cntMedia_ManagerCancel" div_id="{$div_id|escape}">Отменить</a>
                {/if}
            </td>

            {if $mode == 'item' }
            <td align="right">
                <img src="{$SPIcfg.dir.pubsite_styles|escape}null.gif" class="cntMediaIco cntMediaIco_delete" align="absmiddle" /> <a nohref="nohref" class="handler__cntMedia_ManagerSubmitDeleteForm" div_id="{$div_id|escape}">Удалить элемент</a>
            </td>
            {/if}
        </tr>
        </table>
    </div>
</div>

{include file="stddecor.form.close.tpl" }

</form>
</div>
